package com.makingTeam.server.controller;

import com.makingTeam.comment.annotation.ApiLog;
import com.makingTeam.comment.enums.OperateEnum;
import com.makingTeam.comment.result.JsonResult;
import com.makingTeam.server.service.Goods1Service;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * user: pzy
 * date: 2025/4/8 10:44
 */
@RestController
@RequestMapping("/login/")
@Api(tags = "登录")
@Slf4j(topic = "api-log")
public class LoginController {

    @Resource
    private Goods1Service goods1Service;

    // 会话登录接口
    @PostMapping("doLogin")
    @ApiLog(method = "登录",type= OperateEnum.OTHER)
    public JsonResult<Object> doLogin(String name, String pwd) {
        Object login = goods1Service.login(name, pwd);
        return JsonResult.success("登录成功",login);
    }

    @PostMapping("updateLogin")
    @ApiLog(method = "修改登录",type= OperateEnum.OTHER)
    public JsonResult<Object> updateLogin(String name, String pwd) {
        Object login = goods1Service.updateLogin(name, pwd);
        return JsonResult.success("登录成功",login);
    }

    @PostMapping("del")
    @ApiLog(method = "删除缓存",type= OperateEnum.OTHER)
    public JsonResult<Object> del(String name) {
        goods1Service.del(name);
        return JsonResult.success("删除成功",null);
    }


}
